package com.wngbms.netty.seatdemo.comm;

public enum EncryptionType {
    NON((byte) 0b000, (byte) 3, "无加密"),
    BASE64((byte) 0b001, (byte) 3, "BASE64加密"),
    CUSTOMER((byte) 0b111, (byte) 3, "自定义加密"),

    ;
    byte type;
    byte bitLen; // 占用的比特位数
    String desc;

    EncryptionType(byte type, byte bitLen, String desc) {
        this.type = type;
        this.bitLen = bitLen;
        this.desc = desc;
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static EncryptionType find(byte val) {
        EncryptionType[] values = EncryptionType.values();
        for (int i = 0; i < values.length; i++) {
            if (values[i].getType() == val) {
                return values[i];
            }
        }
        return null;
    }

}
